package practice_2025_11.practice_11_17;

class Solution {
    /**
     * 是否所有 1 都至少相隔 k 个元素
     * 模拟
     * @param nums
     * @param k
     * @return
     */
    public boolean kLengthApart(int[] nums, int k) {
        int prev = -1;
        for(int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                if (prev != -1 && i - prev <= k) {
                    return false;
                }
                prev = i;
            }
        }
        return true;
    }
}